<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Fuel Class - Fuel Documentation</title>
	<link href="../assets/css/main.css" media="screen" rel="stylesheet" />
	<script type="text/javascript" src="../assets/js/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="../assets/js/nav.js"></script>
	<script type="text/javascript" src="../assets/js/highlight.pack.js"></script>
	<script type="text/javascript">
		$(function() {
			show_nav('classes', '../');
		});
		hljs.tabReplace = '    ';
		hljs.initHighlightingOnLoad();
	</script>
</head>
<body>

	<header>
		<h1>Fuel Documentation</h1>
	</header>

	<div id="main-nav"></div>

	<section id="content">
		<h2>Fuel Class</h2>

		<p>
			The Fuel class contains the core methods of the Fuel framework.
			The public methods in this class that can be used in your application are documented here.
			All other methods are for internal use only, and should not be used.</p>

		<h3 id="class_constants">Class constants</h3>

		<p style="margin-bottom:10px;">Environment constants. These are used in your config.php to define the application environment:</p>
		<table class="config">
			<tbody>
				<tr class="header">
					<th>Name</th>
					<th>Type</th>
					<th>Value</th>
					<th>Description</th>
				</tr>
				<tr>
					<th>TEST</th>
					<td>string</td>
					<td><pre class="php"><code>'test'</code></pre></td>
					<td>
						Identifies the TEST environment.
					</td>
				</tr>
				<tr>
					<th>DEVELOPMENT</th>
					<td>string</td>
					<td><pre class="php"><code>'dev'</code></pre></td>
					<td>
						Identifies the DEVELOPMENT environment.
					</td>
				</tr>
				<tr>
					<th>STAGE</th>
					<td>string</td>
					<td><pre class="php"><code>'stage'</code></pre></td>
					<td>
						Identifies the STAGE environment.
					</td>
				</tr>
				<tr>
					<th>PRODUCTION</th>
					<td>string</td>
					<td><pre class="php"><code>'production'</code></pre></td>
					<td>
						Identifies the PRODUCTION environment.
					</td>
				</tr>
			</tbody>
		</table>

		<p id="log_constants" style="margin-bottom:10px;">Logging constants. These are used by the <a href="log.html">Log</a> class, and by the function <a href="log.html#function_logger">logger():</a></p>
		<table class="config">
			<tbody>
				<tr class="header">
					<th>Name</th>
					<th>Type</th>
					<th>Value</th>
					<th>Description</th>
				</tr>
				<tr>
					<th>L_NONE</th>
					<td>integer</td>
					<td><pre class="php"><code>0</code></pre></td>
					<td>
						Logging level 0: do not log.
					</td>
				</tr>
				<tr>
					<th>L_ERROR</th>
					<td>integer</td>
					<td><pre class="php"><code>1</code></pre></td>
					<td>
						Indicates an error message is logged.
					</td>
				</tr>
				<tr>
					<th>L_WARNING</th>
					<td>integer</td>
					<td><pre class="php"><code>2</code></pre></td>
					<td>
						Indicates an warning is logged.
					</td>
				</tr>
				<tr>
					<th>L_DEBUG</th>
					<td>integer</td>
					<td><pre class="php"><code>3</code></pre></td>
					<td>
						Indicates a debug message is logged.
					</td>
				</tr>
				<tr>
					<th>L_INFO</th>
					<td>integer</td>
					<td><pre class="php"><code>4</code></pre></td>
					<td>
						Indicates an informational message is logged.
					</td>
				</tr>
				<tr>
					<th>L_ALL</th>
					<td>integer</td>
					<td><pre class="php"><code>5</code></pre></td>
					<td>
						All logging levels.
					</td>
				</tr>
			</tbody>
		</table>

		<p style="margin-bottom:10px;">Other constants:</p>
		<table class="config">
			<tbody>
				<tr class="header">
					<th>Name</th>
					<th>Type</th>
					<th>Value</th>
					<th>Description</th>
				</tr>
				<tr>
					<th>VERSION</th>
					<td>string</td>
					<td><pre class="php"><code>'1.0.1'</code></pre></td>
					<td>
						Version of the current Fuel installation.
					</td>
				</tr>
			</tbody>
		</table>

		<h3>Class properties</h3>

		<p>To be written.</p>

		<article>
			<h4 id="method_find_file">find_file($directory, $file, $ext = '.php', $multiple = false, $cache = true)</h4>
			<p>The <strong>find_file</strong> method is used to locate files in a Fuel application directory structure.</p>
			<p>The method searches through all search paths defined in the active Request instance, the application path, all loaded package paths and the core path (in this order). You can also use the method '<strong>add_path</strong>' to manually add global search paths.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$directory</kbd></th>
								<td><i>required</i></td>
								<td>Relative directory name in which you want to search for files.</td>
							</tr>
							<tr>
								<th><kbd>$file</kbd></th>
								<td><i>required</i></td>
								<td>Name of the file you want to find.</td>
							</tr>
							<tr>
								<th><kbd>$ext</kbd></th>
								<td><pre class="php"><code>'.php'</code></pre></td>
								<td>Extension of the file you're looking for. Note the leading dot, which is required!</td>
							</tr>
							<tr>
								<th><kbd>$multiple</kbd></th>
								<td><pre class="php"><code>false</code></pre></td>
								<td>If <strong>false</strong>, the first file found is returned. If <strong>true</strong>, an array of all files found that match the criteria is returned.</td>
							</tr>
							<tr>
								<th><kbd>$cache</kbd></th>
								<td><pre class="php"><code>true</code></pre></td>
								<td>If <strong>true</strong>, the result will be cached for subsequent requests. If <strong>false</strong>, the result will not be cached.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>Mixed, either string or an array of strings.</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// find all views named 'test'
$views = Fuel::find_file('views', 'test', '.php', true);
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_list_files">list_files($directory = null, $filter = '*.php')</h4>
			<p>The <strong>list_files</strong> method gets a list of all the files in a given directory inside all of the loaded search paths (e.g. the cascading file system). This is useful for things like finding all the config files in all the search paths.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$directory</kbd></th>
								<td><i>required</i></td>
								<td>Relative directory name in which you want to search for files.</td>
							</tr>
							<tr>
								<th><kbd>$filter</kbd></th>
								<td><pre class="php"><code>'*.php'</code></pre></td>
								<td>Filename filter, to be used in the search.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>Array</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// find all config files in this Fuel installation
$files = Fuel::list_files('config');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_addpath">add_path($path, $prefix = false)</h4>
			<p>The <strong>add_path</strong> method allows you to add a global search path. The search paths are used by Fuel::find_file() to locate files within your application.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$path</kbd></th>
								<td><i>required</i></td>
								<td>Path to be added to the list of global search paths</td>
							</tr>
							<tr>
								<th><kbd>$prefix</kbd></th>
								<td><pre class="php"><code>false</code></pre></td>
								<td>If <strong>false</strong>, the path will be added to the search path list. If <strong>true</strong>, it will be prepended to the list.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><i>void</i></td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// prepend the applications myfiles folder to the global search path
Fuel::add_path(APPPATH.'myfiles'.DS, true);
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_get_paths">get_paths()</h4>
			<p>The <strong>get_paths</strong> method returns the defined list of search paths.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>No</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><i>void</i></td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// get the defined search paths
$paths = Fuel::get_paths();
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_load">load($file)</h4>
			<p>The <strong>load</strong> method loads (includes) a given file, and returns the results. This method is used for example to load configuration files, which return an array of configuration settings.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$file</kbd></th>
								<td><i>required</i></td>
								<td>Filename of the file to be loaded</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td>Mixed</td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// load a PHP file
if (Fuel::load('myfile.php'))
{
	echo "MyFile was loaded successfully";
}
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
			<p class="note"> Note that if the included file does NOT contain a <strong>return</strong> statement, load() will return <strong>1</strong> if the load was successful, or <strong>0</strong> if the file could not be loaded!</p>
		</article>

		<article>
			<h4 id="method_add_package">add_package($package)</h4>
			<p>The <strong>add_package</strong> method allows you to add one or more packages at runtime.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$package</kbd></th>
								<td><i>required</i></td>
								<td>Name of the package to be loaded, or an array of packages and package paths.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><i>void</i></td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// load the ORM package
Fuel::add_package('ORM');

// add multiple packages from a single package installation
Fuel::add_package( array('First' => PKGPATH.'my'.DS.'first'.DS, 'Last' => PKGPATH.'my'.DS.'last'.DS) );
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

		<article>
			<h4 id="method_remove_package">remove_package($package)</h4>
			<p>The <strong>remove_package</strong> method allows you to remove a package at runtime.</p>
			<table class="method">
				<tbody>
				<tr>
					<th class="legend">Static</th>
					<td>Yes</td>
				</tr>
				<tr>
					<th>Parameters</th>
					<td>
						<table class="parameters">
							<tr>
								<th>Param</th>
								<th>Default</th>
								<th class="description">Description</th>
							</tr>
							<tr>
								<th><kbd>$package</kbd></th>
								<td><i>required</i></td>
								<td>Name of the package to be removed.</td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<th>Returns</th>
					<td><i>void</i></td>
				</tr>
				<tr>
					<th>Example</th>
					<td>
						<pre class="php"><code>// remove the ORM package
Fuel::remove_package('ORM');
</code></pre>
					</td>
				</tr>
				</tbody>
			</table>
		</article>

	</section>

	<section id="footer">
		<p>
			<a href="http://fuelphp.com">Fuel</a> is released under the MIT license.<br />
			&copy; 2010 - 2011 Fuel Development Team
		</p>
	</section>

</body>
</html>
